package org.opensourceway.sbom.dao;

import org.opensourceway.sbom.model.entity.ExternalPurlRef;
import org.opensourceway.sbom.model.pojo.vo.sbom.PackagePurlAndBranchVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.UUID;

public interface PackagePurlRepository extends JpaRepository<PackagePurlAndBranchVo, UUID>, JpaSpecificationExecutor<PackagePurlAndBranchVo> {
    @Query(value = "select epr.id,epr.purl,pd.name\n" +
            "from external_purl_ref epr join package p on epr.pkg_id = p.id join sbom s on p.sbom_id = s.id join product pd on s.product_id = pd.id", nativeQuery = true)
    Page<PackagePurlAndBranchVo> queryAllPackagePurlAndBranch(Pageable pageable);
}
